<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>xxx的留言 - 听到微笑的博客</title>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/css/style.css">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/css/font-awesome.min.css">
<link rel="apple-touch-icon-precomposed" href="${pageContext.request.contextPath }/images/icon/icon.png">
<link rel="shortcut icon" href="${pageContext.request.contextPath }/images/icon/favicon.ico">
<script src="${pageContext.request.contextPath }/js/jquery-2.1.4.min.js"></script>
</head>
<body class="user-select">
	<section class="container-fluid">
		<jsp:include page="common/top.jsp"></jsp:include>
		<div class="row">
			<jsp:include page="common/left.jsp"></jsp:include>
			<div class="col-sm-9 col-sm-offset-3 col-md-10 col-lg-10 col-md-offset-2 main" id="main">
				<div class="row">
					<div class="col-md-8">
						<h1 class="page-header">留言信息</h1>
						<form action="${pageContext.request.contextPath }/category/update.action" method="post" autocomplete="off">
							<input type="hidden" name="id" value="${category.id }">
							<div class="form-group">
								<label for="category-name">留言主题</label>
								<input type="text" value="${message.title }" class="form-control" required autocomplete="off" readonly="readonly">
							</div>
							<div class="form-group">
								<label for="category-describe">描述</label>
								<textarea class="form-control" id="category-describe" name="description" rows="10" autocomplete="off" readonly="readonly">${message.content }</textarea>
							</div>
							<div class="form-group">
								<label for="category-alias">用户名</label>
								<input type="text" value="${message.user.username }" class="form-control" required autocomplete="off" readonly="readonly">
							</div>
							<div class="form-group">
								<label for="category-alias">联系人邮箱</label>
								<input type="text" value="${message.email }" class="form-control" required autocomplete="off" readonly="readonly">
							</div>
							<div class="form-group">
								<label for="category-alias">留言日期</label>
								<input type="text" value="${message.stringCreatetime }" class="form-control" required autocomplete="off" readonly="readonly">
							</div>
							<a href="" onclick="reverseTagReply(${message.id})" class="btn btn-primary">
								<c:choose>
									<c:when test="${message.tagReply==0 }">
										标记为已处理
									</c:when>
									<c:otherwise>
										标记为未处理
									</c:otherwise>
								</c:choose>
							</a>
							<a onclick="deleteMessage(${message.id})" class="btn btn-primary">删除该留言</a>
						</form>
					</div>
				</div>
			</div>
		</div>
	</section>
	<script src="${pageContext.request.contextPath }/js/bootstrap.min.js"></script>
	<script src="${pageContext.request.contextPath }/js/admin-scripts.js"></script>
	<script type="text/javascript">
		function deleteMessage(messageId) {
			if (confirm("该操作不可逆，继续操作请点击确认")) {
				$.post(
					"${pageContext.request.contextPath}/message/delete.action",
					{
						"messageId" : messageId
					},
					function(data) {
						if (data.status == "ok") {
							window.location.href = "${pageContext.request.contextPath}/message/list.html";
						}
					},
					"json"
				);
			}
		}
		
		function reverseTagReply(messageId){
			$.post(
					"${pageContext.request.contextPath}/message/reverse-tagreply.action",
					{
						"messageId" : messageId
					},
					function(data) {
						if (data.status == "ok") {
							window.location.href = "${pageContext.request.contextPath}/message/list.html";
						}
					},
					"json"
				);
		}
		$(function() {
			$("#message-board").addClass('active');
		})
	</script>
</body>
</html>
